<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>我的测试站点</title>
</head>

<body>
  <canvas id="game" width="960" height="540"></canvas>
  <script>
    function loadText(url) {
      return new Promise((resolve, reject) => {
        const xhr = new XMLHttpRequest();
        xhr.onload = () => {
          resolve(xhr.responseText);
        }
        xhr.open("get", url);
        xhr.send();
      })
    }
    function loadScript(url) {
      return new Promise((resolve, reject) => {
        const script = document.createElement("script");
        script.onload = () => resolve();
        script.src = url;
        document.body.appendChild(script);
      })
    }
    async function run() {
      const content = await loadText("config.json");
      window["configData"] = JSON.parse(content);
      const javascriptFiles = window["configData"].scripts;
      for (let item of javascriptFiles) {
        await loadScript(item);
      }
    }
    run();
  </script>
</body>

</html>